/**
 *
 */
package com.angel.io.validators.impl;

import java.lang.reflect.Method;

import com.angel.common.helpers.AnnotationHelper;
import com.angel.common.helpers.ReflectionHelper;
import com.angel.io.annotations.RowProcessor;
import com.angel.io.exceptions.RowProcessorCommandValidatorException;
import com.angel.io.validators.RowProcessorCommandValidator;

/**
 * @author William
 *
 */
public class OnlyOneRowProcessorAnnotationValidator implements RowProcessorCommandValidator{

	public void validate(Class<?> importRowCommandClass) throws RowProcessorCommandValidatorException {
		Method[] methods = ReflectionHelper.getAllMethodFor(importRowCommandClass);
		boolean hasOnlyOne = AnnotationHelper.hasOnlyOneAnnotationInstance(methods, RowProcessor.class);
		if(!hasOnlyOne){
			throw new RowProcessorCommandValidatorException("Class [" + importRowCommandClass.getCanonicalName() + "] must have one and only one method with RowProcessor annotation.");
		}
	}


}
